package logic

import (
	"context"
	"wechat/userrpc/userrpc"

	"wechat/api/internal/svc"
	"wechat/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type FriendDelLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewFriendDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FriendDelLogic {
	return &FriendDelLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *FriendDelLogic) FriendDel(req *types.FriendDelRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	del, err := l.svcCtx.UserRpc.FriendDel(l.ctx, &userrpc.FriendDelRequest{
		UserId:   req.UserId,
		FriendId: req.FriendId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "删除好友成功",
		Code:    200,
		Data:    del,
	}, nil
}
